//
//  AddNewBuyersViewController.m
//  GLGW_Shoping
//
//  Created by yang on 2018/12/10.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "AddNewBuyersViewController.h"
#import "AddNewBuyersViewModel.h"
#import "AdressChangeViewController.h"

@interface AddNewBuyersViewController ()<AddNewBuyersDelegate>
@property (nonatomic,strong) AddNewBuyersViewModel * buyersViewModel;

@end

@implementation AddNewBuyersViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.buyersViewModel = [[AddNewBuyersViewModel alloc] initWithViewToViewModel:self.groupedTableView theSuperView:self.view theInforsModel:_s_inforModel];
    self.buyersViewModel.delegate = self;
    if (_s_inforModel) {
        self.title = @"编辑买家信息";
        NSInteger tagType;
        NSString * coopStr;
        if (self.s_inforModel.status == 1) {
            tagType = 102;
            coopStr = @"取消合作";
        }else{
            tagType = 101;
            coopStr = @"合作";
        }
        [self addNavigationItemWithTitles:@[coopStr] isLeft:NO target:self action:@selector(cancelAction:) tags:@[@(tagType)] theButTitColor:[UIColor colorWithHexString:@"#666666"] titFont:SYSTEMFONT(14)];
    }else{
        self.title = @"新增买家信息";
    }
}

-(void)cancelAction:(UIButton *)sender{
    [self.buyersViewModel cancelTheCooperation:sender.tag-100];
}
#pragma amrk -- set
-(void)setS_inforModel:(ServiceBuyersModel_Infos *)s_inforModel{
    _s_inforModel = s_inforModel;
}
#pragma mark -- AddNewBuyersDelegate
-(void)requestDataSuccess:(AddOrEditType)addType{
    DLog(@"操作完成");
    if (self.Block_EditOrAddAction) {
        self.Block_EditOrAddAction(addType);
    }
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)selectAdress{
    AdressChangeViewController * adressVC = [AdressChangeViewController new];
    [self.navigationController pushViewController:adressVC animated:YES];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
